package spring.yongongsystem.mapper;

import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import spring.yongongsystem.POJO.dto.CategoryPageQueryDTO;
import spring.yongongsystem.POJO.entity.Category;


@Mapper
public interface CategoryMapper {
    /**
     * 分页查询
     * @param categoryPageQueryDTO
     * @return
     */
    Page<Category> pageQuery(CategoryPageQueryDTO categoryPageQueryDTO);
    /**
     * 根据id删除分类
     * @param id
     */
    @Delete("delete from category where id = #{id}")
    void deleteById(Long id);

    /**
     * 根据id编辑分类
     * @param category
     */
    void update(Category category);
    @Insert("insert into category (category_name)" +
            " VALUES" +
            " (#{categoryName})")
    void insert(Category category);

    @Select("SELECT COUNT(*) FROM category;")
    long count();
}
